package com.zhuiyun.project.api.appuserreport.mapper;

import com.zhuiyun.project.api.addfriend.model.AppFriendModel;
import com.zhuiyun.project.api.appuserreport.entity.UserReport;
import com.zhuiyun.project.api.appuserreport.model.AppUerReportModel;
import com.zhuiyun.project.common.mapper.BaseMapper;
import com.zhuiyun.project.util.pageUtil.PageRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AppUserReportMapper extends BaseMapper<UserReport> {


    /**
     * 查询被举报账号信息
     *
     * @return java.util.List<com.zhuiyun.project.api.appuserreport.entity.userReport>
     * @author 温
     * @date 2023/6/27 10:15
     * @parameter [reportedUserId, pageRequest]
     */
    @Select("<script>SELECT * FROM user_report  WHERE del_flag = 0 " +
            "<when test='reportType!=&quot;&quot; and reportType!=null'>" +
            "and user_report.report_type like concat('%',#{reportType},'%')  </when> ORDER BY report_time desc</script>")
    List<AppUerReportModel> getUserReportsBy(AppUerReportModel appUerReportModel);


    /**
     * 同意举报申请 （警告）
     *
     * @return int
     * @author 温
     * @date 2023/6/27 10:14
     * @parameter [id]
     */
    @Update("update user_report set report_status=1,processing_result=1,update_time=now(),processing_time=now(),processor= #{processor} where id=#{id}")
    int userReport1(Integer id,String processor);

    /**
     * 同意举报申请 （注销）
     *
     * @return int
     * @author 温
     * @date 2023/6/27 10:14
     * @parameter [id]
     */
    @Update("update user_report set report_status=1,processing_result=3,update_time=now(),processing_time=now(),processor= #{processor} where id=#{id}")
    int userReport2(Integer id,String processor);
    /**
     * 驳回原因
     *
     * @return int
     * @author 温
     * @date 2023/6/29 10:51
     * @parameter [userReport]
     */
    @Update("update user_report set processing_result = 2, report_status=1,rejection_reason=#{rejectionReason},update_time=now(),processing_time=now(),processor= #{processor} where id=#{id}")
    int userReportReject(UserReport userReport);


    /**
     * @param
     * @Author kdj
     * @Description 查询  举报人记录
     * @Date 2023/8/14 15:47
     * @Return java.util.List<com.zhuiyun.project.api.appuserreport.entity.UserReport>
     */
    @Select("<script>  SELECT\n" +
            "\ta.* \n" +
            "FROM\n" +
            "\tsys_dict_data a\n" +
            "\tLEFT JOIN sys_dict_type b ON a.dict_id = b.dict_id\n" +
            "where a.dict_id = 4" +
            "</script>")
    List<UserReport> userReportList();


    /**
     * @param userReport
     * @Author kdj
     * @Description 添加审核记录
     * @Date 2023/8/14 15:45
     * @Return int
     */
    @Insert("insert into user_report(reporting_user_id,reported_user_id,reported_user_name,reporting_user_name,report_type,report_details,report_time,report_status,processing_time,processing_result,rejection_reason,create_time,update_time,del_flag)" +
            "values(#{reportingUserId},#{reportedUserId},#{reportedUserName},#{reportingUserName},#{reportType},#{reportDetails},#{reportTime},#{reportStatus},#{processingTime},#{processingResult},#{rejectionReason},#{createTime},#{updateTime},#{delFlag})")
    int userReportsy(UserReport userReport);


}
